//package com.wulaobo.test;
//
//import com.wulaobo.pojo.Event;
//import org.apache.flink.api.common.functions.MapFunction;
//import org.apache.flink.api.common.functions.ReduceFunction;
//import org.apache.flink.api.java.ExecutionEnvironment;
//import org.apache.flink.api.java.operators.DataSource;
//import org.apache.flink.api.java.operators.MapOperator;
//import org.apache.flink.api.java.tuple.Tuple2;
//
//public class BatchReduceDemo {
//
//    public static void main(String[] args) throws Exception {
//
//        ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
//        DataSource<Event> dataSource = env.fromElements(
//                new Event("Mary", "./home", 1000L),
//                new Event("Bob", "./cart", 2000L),
//                new Event("Jack", "./home", 3000L),
//                new Event("Rose", "./order", 4000L),
//                new Event("Joe", "./shoping", 5000L),
//                new Event("Smith", "./product", 6000L));
//
//        MapOperator<Event, Tuple2<String, Long>> mapOperator = dataSource.map(new MapFunction<Event, Tuple2<String, Long>>() {
//            @Override
//            public Tuple2<String, Long> map(Event e) throws Exception {
//                return Tuple2.of(e.user, 1L);
//            }
//        });
//
//        mapOperator.reduce(new ReduceFunction<Tuple2<String, Long>>() {
//            @Override
//            public Tuple2<String, Long> reduce(Tuple2<String, Long> value1,
//                                               Tuple2<String, Long> value2) throws Exception {
//                // 每到一条数据，用户 pv 的统计值加 1
//                return Tuple2.of(value2.f0, value1.f1 + value2.f1);
//            }
//        }).print();
//
//
//    }
//
//}
